/*
    www.cguage.com
    1.1 找最长连续串
*/

#include <iostream>
#include <sstream>
#include <cassert>
using namespace std;

#ifndef TEST
#define IN(iss) {                       \
        std::string str;                \
        std::getline(std::cin, str);    \
        iss.str(str);                   \
    }
#define OUT(s) std::cout << s
#endif

#define READ_N(iss, n) {    \
    iss >> n;               \
    iss.ignore(1, ',');     \
}

int main() {
    istringstream iss;
    IN(iss);
    assert(!iss.eof());
    int n = 0;
    READ_N(iss, n);
    int curNum = n;         // 当前统计序列长度的数字
    int curTimes = 1;       // 当前数字重复次数
    int rstNum = 0;         // 重复最多的那个数字
    int maxTimes = 0;       // 重复最多的次数

    auto s = iss.str();

    while (!iss.eof()) {
        READ_N(iss, n);
        // 统计当前序列的长度
        if (n == curNum) {
            ++curTimes;
        } else {
            if (curTimes > maxTimes) {
                maxTimes = curTimes;
                rstNum = curNum;
            }
            // 切换到下一个
            curNum = n;
            curTimes = 1;
        }
    }

    // 把结果组装成序列
    ostringstream oss;
    for (int i = 0; i < maxTimes - 1; ++i) {
        oss << rstNum << ",";
    }
    oss << rstNum;
    OUT(oss.str());
    return 0;
}

#ifdef TEST
struct TestCase CASES[] = {
    /*0*/{"1,2,2,3,3,3,4,5,5,6", "3,3,3"},
    /*1*/{"1,2,3,4,5", "1"},
    /*2*/{"-1,-1,-1,0,2,2", "-1,-1,-1"},
};
#endif